package com.wanbangee.marksystem.service.imp;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.wanbangee.marksystem.dao.UClassSubjectRelationDao;
import com.wanbangee.marksystem.entities.USubjectClassRelation;
import com.wanbangee.marksystem.entities.UTeacher;
import com.wanbangee.marksystem.service.UClassSubjectRelationService;
@Service
public class UClassSubjectRelationServicelmp implements UClassSubjectRelationService {

	@Autowired
	private UClassSubjectRelationDao uClassSubjectRelationDao;
	@Override 
	public List<USubjectClassRelation> selectUSubjectClassRelationByclaId(String claNm) {
		// TODO Auto-generated method stub
		return this.uClassSubjectRelationDao.selectUSubjectClassRelationByclaId(claNm);
	}
	@Override
	public List<UTeacher> selectTeaBySubIdAndSchId(Integer subId, Integer schId) {
		// TODO Auto-generated method stub
		return this.uClassSubjectRelationDao.selectTeaBySubIdAndSchId(subId, schId);
	}
	@Override
	public Integer insertSubjectAdnClassRelation(USubjectClassRelation uSubjectClassRelation) {
		// TODO Auto-generated method stub
		return this.uClassSubjectRelationDao.insertSubjectAdnClassRelation(uSubjectClassRelation);
	}
 
	 public Integer deleteTeaByrelId(Integer relId) {
		return this.uClassSubjectRelationDao.deleteTeaByrelId(relId);
	 }
	 
	 public USubjectClassRelation selectByrelId(Integer relId) {
		 return this.uClassSubjectRelationDao.selectByrelId(relId);
	 }
	 
	 @Transactional
	 public Integer updateUSubjectClassRelation(USubjectClassRelation uSubjectClassRelation) {
		Integer delete= this.uClassSubjectRelationDao.deleteTeaByrelId(uSubjectClassRelation.getRelId());
		if(delete==1) {
			Integer insert= this.uClassSubjectRelationDao.insertSubjectAdnClassRelation(uSubjectClassRelation);
			 return 1; 
		}
		 return 0; 
	 }
}
